def Qsort(l):
    if len(l) <= 1: return l
    greater, less = [], []
    pivot = l.pop(len(l) / 2)
    for num in l:
        if num < pivot:
            less.append(num)
        else:
            greater.append(num)
    return Qsort(less) + [pivot] + Qsort(greater)

arr = [2, 3, 5, 8, 7, 1, 6, 9, 4]
print "origin:", arr
print "sorted:", Qsort(arr)
